//https://leetcode-cn.com/problems/search-insert-position/

//二分查找i
int searchInsert(int* nums, int numsSize, int target)
{
    int left = 0;
    int right = numsSize - 1;
    int mid = (left + right) / 2;

    if(nums[0] > target)
        return 0;
    while(left <= right)
    {
        if(target < nums[mid])
        {
            right = mid - 1;
            mid = (left + right) / 2;

        }
        else if(target > nums[mid])
        {
            left = mid + 1;
            mid = (left + right) / 2;

        }
        else
        {
            return mid;
        }

    }

    return mid + 1;

}